package com.leetcode.August;

import javax.swing.tree.TreeNode;
import java.util.ArrayList;
import java.util.List;


/**
 * @Description: 94. 二叉树的中序遍历
 * @Author: Mr.Fxy
 * @CreateTime: 2024-08-28 16:32
 */
public class LC94二叉树的中序遍历 {
    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> res = new ArrayList<Integer>();
        inorder(root, res);
        return res;
    }

    public void inorder(TreeNode root, List<Integer> res) {
        if (root == null) return;
        inorder(root.left, res);
        res.add(root.val);
        inorder(root.right, res);
    }
}
